package JLB_Chapter_07;

import java.util.Random;

class Test {
    int i = 0;
}
public class FinalData {
    static Random rand = new Random();
    // 声明一个final常量
    private final int VALUE_1 = 9;
    // 声明一个final,static常量
    private static final int VALUE_2 = 10;
    // 声明一个fianl引用
    private final Test test = new Test();
    // 声明一个不是fianl的引用
    private Test test2 = new Test();
    // 声明一个定义为final的数组
    private final int[] a = {1, 2, 3, 4, 5, 6, 7};
    private final int i4 = rand.nextInt(20);
    private static final int i5 = rand.nextInt(20);

    public String toString() {
        return i4 + " " + i5 + " ";
    }

    public static void main(String[] args) {
        FinalData data =  new FinalData();
        //可以对指定为final的引用中的成员变量赋值
        //但不能将定义为final的引用指向其他引用
        //data.test = new Test();
        //data.VALUE_2;
        data.test2 = new Test();
        for(int i = 0; i < data.a.length; i++ ) {
            //a[i] = 9
        }
        System.out.println(data);
        System.out.println("data2");
        System.out.println(new FinalData());
        System.out.println(data);
    }
}